#include <bits/stdc++.h>
using namespace std;
const int N = 10e5+1;

struct Detect{
    int d;
    bool detected;
};

bool cmp(Detect d1,Detect d2){
    return d1.d<d2.d;
}

struct Car{
    int d,v,a;
    vector<Detect> bt;

    double GetSpeed(int D){
        if(D<d)return -1;
        double res = sqrt(v*v+2*a*(D-d));
        if(res<=0)return 0;
        return res;
    }

};

void solve(){
    vector<Car> cars;
    vector<Detect> _detect;
    int n,m,l,v;
    cin>>n>>m>>l>>v;

    for(int i=0;i<n;i++){
        int d,v,a;
        cin>>d>>v>>a;
        Car c;
        c.d=d;c.v=v;c.a=a;
        cars.push_back(c);
    }

    for(int i=0;i<m;i++){
        int d;
        cin>>d;
        Detect D;
        D.d=d;D.detected=false;
        _detect.push_back(D);
    }

    int ans1=0;
    for(Car &car : cars){
        bool rec=false;

        for(Detect &det : _detect){

            if(car.GetSpeed(det.d)>v){
                if(!rec){
                    ans1++;
                    rec=true;
                }
                car.bt.push_back(det);

            }
        }
    }

    vector<Detect> u;
    for(Car &car : cars){
        for(Detect d : car.bt){
            u.push_back(d);
        }
    }
    sort(u.begin(),u.end(),cmp);

    int cnt=0,last=u[0].d;
    for(auto i : u){
        if(i.d!=last){
            cnt++;
            last=i.d;
        }
    }
    cout<<ans1<<' '<<cnt<<endl<<flush;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)solve();
    return 0;
}
